<%--
  Created by IntelliJ IDEA.
  User: 123
  Date: 2020/7/8
  Time: 15:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="true" %>
<%@include file="/common/com.jsp"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>

<html>
<head>
    <title>Title</title>
</head>
<body>
<div id="mx">
    <Collapse v-model="Pane1">
        <Panel name="Pane1">
            搜索栏
            <p slot="content">
                <i-form :label-width="70" inline>
                    <Form-Item label="订单编号:">
                        <i-input v-model="managementVo.userCode"></i-input>
                    </Form-Item>

                    <i-button type="primary" @click="pageNo=1;getmxList();">搜索</i-button>
                </i-form>
            </p>

        </Panel>
    </Collapse>
<card>
<shiro:hasPermission name="mxchaser:add">

        <i-button type="info"ghost @click="add">添加</i-button>
</shiro:hasPermission>
    <i-Button type="info"  shape="circle"  ghost @click="shuaxin"><Icon type="ios-refresh"></Icon>刷新</i-Button>
</card>
    <i-table :columns="columns" :data="data" height="400" Border stripe @on-selection-change="tableSelect=arguments[0]">
        <template slot-scope="{row,index}" slot="aliction">
<shiro:hasPermission name="mxchaser:err">
    <i-Button type="info" Icon="md-checkmark" ghost shape="circle" @click="err(row,index)">查看该商品</i-Button>
</shiro:hasPermission>
            <shiro:hasPermission name="mxchaser:del">
                <i-Button type="warning" Icon="ios-close-circle"ghost  shape="circle" @click="del(row,index)">删除该商品</i-Button>            </shiro:hasPermission>
<shiro:hasPermission name="mxchaser:go">
    <i-Button type="success" Icon="ios-close-circle" ghost shape="circle" @click="go(row,index)">进入入库单</i-Button>
</shiro:hasPermission>
        </template>
        <template slot-scope="{row,index}" slot="rolist">
            {{row.pur.purName}}
        </template>

    </i-table>
    <Modal v-model="modalgo" title="添加入库单" @on-ok="dogo">
        <h3>是否添加到入库单</h3>
    </Modal>
    <Modal v-model="modaladd"  title="添加供应商联系人" @on-ok="doadd">
        <i-form :label-width="80">
            <Form-Item label="采购订单编号">
                <i-input v-model="count.mxLingcode"></i-input>
            </Form-Item>
            <Form-Item label="商品名称">
                <i-input v-model="count.mxLingname"></i-input>
            </Form-Item>
            <Form-Item label="单价">
                <i-input v-model="count.mxDmoney"></i-input>
            </Form-Item>
            <Form-Item label="数量">
                <i-input v-model="count.mxSmoney"></i-input>
            </Form-Item>
            <Form-Item label="总价">
                <i-input v-model="count.mxZmoney"></i-input>
            </Form-Item>
        </i-form>
    </Modal>
    <Modal v-model="modalerr" title="查询明细内容" @on-ok="doerr">
        <div>
            <Card :bordered="false">
                <h3>采购订单编号:{{count.mxLingcode}}</h3>
                <h3>商品名称:{{count.mxLingname}}</h3>
                <h3>单价:{{count.mxDmoney}}</h3>
                <h3>数量:{{count.mxSmoney}}</h3>
                <h3>总价:{{count.mxZmoney}}</h3>
            </Card>
        </div>
    </Modal>
    <template>
        <Page :total="total"
              show-total
              show-elevator
              :page-size="pageSize"
              style="margin-left: 330px;"
              :current.sync="pageNo"
              show-sizer
              prev-text="上一页"
              next-text="下一页"
              :page-size-opts="[5,10,15,20]"
              @on-page-size-change="pageSize=arguments[0];getmxList();"
              @on-change="getmxList"/>
    </template>

</div>
</body>
<script>
    new Vue({
        el:"#mx",
        data:{
            columns:[
                {title:"采购订单编号",key:"mxLingcode"},
                {title:"商品名称",key:"mxLingname"},
                {title:"单价",key:"mxDmoney"},
                {title:"数量",key:"mxSmoney"},
/*
                {title:"采购员",key:"mxLingroot"},
*/
                {title:"采购员",slot:"rolist"},
                {title:"总价",key:"mxZmoney"},
                {title:"操作",slot:"aliction"},

            ],
            data:[],
            count:{},
            rootlist:{},
            modaladd:false,
            modalerr:false,
            managementVo:{},
            total:50,
            pageSize:5,
            pageNo:1,
        },
        mounted(){
            this.getmxList();
            this.getRootList();
        },
        methods:{
            getmxList(){
                axios.get(`${apath}/mx/count/mxlist/${this.pageSize}/${this.pageNo}`,{params:this.managementVo})

                            .then(({data})=>{
                                this.data=data.result.record;
                                this.total=data.result.total

                    })
            },
            getRootList(){
                axios.get(`${apath}/sm/lin/select`)
                    .then(({data})=>{
                        this.rootlist=data.result;
                    })
            },
            add(){
                this.count = {};
                this.modaladd=true;
            },
            doadd(){
                axios.post(`${apath}/mx/count/add`,this.count)
                    .then(({data})=>{
                        iview.Message.success({content:data.msg})
                        this.getmxList();
                    })
            },
            shuaxin(){
                location.reload();
            },
            err(row,index){
                this.count = row;
                this.modalerr=true;
            },

            doerr(){
                    this.$nextTick(()=>{

                    axios.get(`${apath}/mx/count/err/${row.id}`,this.count)
                        .then(({data})=>{
                            iview.Message.success({content:data.msg})
                            this.getmxList();
                        })
                    })
                },
            del(row,index) {
                let _this =this;
                iview.Modal.confirm({
                    title:"删除此订单！",
                    content:"您确认要删除吗?此操作无法恢复",
                    onOk(){
                        axios.get(`${apath}/mx/count/del/${row.id}`)
                            .then(({data})=>{
                                iview.Message.success({content:data.msg});
                                _this.getmxList();
                            })
                    },
                    onCancel(){
                        iview.Message.info("取消删除成功！")
                    }
                })
            },
            go(row,index){
                this.count=row;
                this.modalgo=true;
            },
            dogo(){
                axios.post(`${apath}/mx/count/go`,this.count)
                    .then(({data})=>{
                        iview.Message.success({content:data.msg})
                        this.getmxList();
                    })
            }
        }

    })
</script>

</html>
